#!/bin/bash
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts
export HOME=/root
export LC_ALL=C
dbus-uuidgen > /var/lib/dbus/machine-id
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl
apt update
#apt upgrade -y
apt -y install vim openssh-server
#apt -y install debconf-utils
apt -y remove update-manager

# switch wayland to xorg
# sed -ie s/#WaylandEnable=false/WaylandEnable=false/ /etc/gdm3/custom.conf

# add startup sound (doesn't work)
#apt -y install sox
#printf "start on startup\nexec play /usr/share/sounds/ubuntu/stereo/desktop-login.ogg">/usr/share/upstart/loginsound.conf

# install dog softwares
wget -O /usr/bin/dog http://eguidedog.net/files/dog
chmod a+x /usr/bin/dog
dog install ekho
dog install orca
dog install tianqi
dog install ibusreader
#apt install -y espeak
#dog install espeakdict

# set orca autostart (this should be actually done by copying /etc/skel/.config/dconf/user)
# dbus-launch --exit-with-session gsettings set org.gnome.desktop.a11y.applications screen-reader-enabled true

# set ubiquity language to zh_CN
echo "ubiquity localechooser/languagelist select zh_CN" | debconf-set-selections

# set ubiquity timezone
echo 'tzdata tzdata/Zones/Asia select Shanghai' | debconf-set-selections

# debconf-set-selections preseed.cfg

# set Chinese input method
#apt install -y ibus-pinyin
#dbus-launch --exit-with-session gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us'), ('ibus', 'libpinyin')]"

# cleanup
apt autoremove -y
apt clean
rm -rf ~/.dog
rm -rf /tmp/* ~/.bash_history ~/.cache
rm /var/lib/dbus/machine-id
rm /sbin/initctl
dpkg-divert --rename --remove /sbin/initctl
umount /proc || umount -lf /proc
umount /sys
umount /dev/pts

echo 'chroot-customize.sh finished'
